﻿<%@ Page Title="Tweet Details" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="TweetDetails.aspx.cs" Inherits="SpessartiteTwitter.TweetDetails" %>

<asp:Content ID="ContentTweetDetails" ContentPlaceHolderID="MainContent" runat="server">

    <div class="row">
        <div class="span12">
            <div class="alert alert-info alert-block">
                <asp:FormView runat="server" ID="FormViewTweetDetails"
                    ItemType="SpessartiteTwitter.Data.Tweet"
                    SelectMethod="FormViewTweetDetails_GetItem">
                    <ItemTemplate>
                        <div class="content-heading ">
                            <img class="img-rounded pull-left" width="200" height="200" src="<%#: Item.Image != null ? "data:image/png;base64," + Convert.ToBase64String(Item.Image) : "" %>" alt="<%#: Item.TweetTitle %>" style='<%# Item.Image != null ? "margin-right: 15px" : "display: none" %>' />
                            <h4><%#: Item.TweetTitle %></h4>
                        </div>
                        <p>
                            by <a runat="server" class="label" href='<%# string.Format("~/UserDetails.aspx?Username={0}", Item.AspNetUser.UserName)%>'><%#: Item.AspNetUser.UserName %></a> | Posted on <%#: Item.DatePosted.ToShortDateString() %>
                        </p>
                        <p class="tweet-text">
                            <%#: Item.TweetText %>
                        </p>
                    </ItemTemplate>
                </asp:FormView>
            </div>
        </div>
    </div>
    <asp:UpdatePanel runat="server" ID="TweetDetailsCommentsUpdatePanel">
        <ContentTemplate>
            <h3>Comments</h3>
            <hr />
            <div id="CommentsHolder" runat="server" class="alert alert-success alert-block tweet-item ">
                <br />
                <ul runat="server" class="unstyled">
                    <asp:ListView ID="ListViewTweetComments" DataKeyNames="CommentId"
                        SelectMethod="ListViewTweetComments_GetData" runat="server"
                        ItemType="SpessartiteTwitter.Data.Comment"
                        OnDataBound="ListViewTweetComments_DataBound">
                        <ItemTemplate>
                            <li runat="server">
                                <div class="comment-text" runat="server"><%#: Item.CommentText %></div>
                                <div class="comment-footer" runat="server">
                                    by <a runat="server" href='<%# string.Format("~/UserDetails.aspx?Username={0}", Item.AspNetUser.UserName)%>'><%#: Item.AspNetUser.UserName %></a> | Posted on <%#: Item.DatePosted %>
                                </div>
                            </li>
                        </ItemTemplate>
                        <EmptyDataTemplate>
                            <strong>No Comments</strong>
                        </EmptyDataTemplate>
                    </asp:ListView>
                </ul>
            </div>
            <asp:DataPager ID="DataPagerComments" runat="server"
                PagedControlID="ListViewTweetComments"
                PageSize="3"
                Visible="false">
                <Fields>
                    <asp:NextPreviousPagerField ShowFirstPageButton="True" ShowNextPageButton="False" ButtonCssClass="btn btn-info" />
                    <asp:NumericPagerField NumericButtonCssClass="btn btn-info" />
                    <asp:NextPreviousPagerField ShowLastPageButton="True" ShowPreviousPageButton="False" ButtonCssClass="btn btn-info" />
                </Fields>
            </asp:DataPager>

        </ContentTemplate>
    </asp:UpdatePanel>

    <asp:Panel ID="PanelAddCommentBox" runat="server" Visible="false">
    <div id="CommentBoxHolder" runat="server">
        <fieldset id="FieldSetAddComment" runat="server">
            <legend runat="server">Add comment</legend>
            <asp:TextBox ID="CommentText" runat="server" TextMode="MultiLine" CssClass="span12 comment-textarea"></asp:TextBox>
            <br />
            <asp:Button ID="ButtonAddComment" Text="Add comment"
                runat="server" OnClick="ButtonAddComment_Click" CssClass="btn btn-info span12" />
        </fieldset>
    </div>
    <br />
</asp:Panel>
</asp:Content>
